package com.hydl.power.mapper;


import com.hydl.power.pojo.OpsReport;
import com.hydl.power.pojo.WorkOrder;
import com.hydl.power.pojo.OrderReport;
import com.hydl.power.pojo.WorkOrder;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface WorkOrderMapper {
    Integer addWorkOrder(WorkOrder workOrder);

    int deleteByPrimaryKey(Integer id);

    WorkOrder selectById(Integer id);

    WorkOrder WorkOrderId(String orderDeliveryId);

    int updateByPrimaryKeySelective(WorkOrder record);

    List<WorkOrder> getList();

    /**
     * 获取最新一条告警记录
     * @return
     */
    WorkOrder getWorkOrderByfaultTime();

    int updateOrderStatus(@Param("id") Integer id, @Param("orderStatus") Integer orderStatus);
    /**
     * 工单派送列表
     * @param pageNum
     * @param pageSize
     * @param begin
     * @param end
     * @param orderTypes
     * @param rank
     * @return
     */
    List<WorkOrder> getAllWorkOrderByList(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize, @Param("beginTime") Long begin, @Param("endTime") Long end,
                                                  @Param("orderTypes") Integer orderTypes, @Param("rank") Integer rank,@Param("orderStatus") Integer orderStatus);

    /**
     *
     * @param pageNum
     * @param pageSize
     * @param begin
     * @param end
     * @param orderStatus
     * @param areaId
     * @param projectId
     * @param roomId
     * @return
     */
    List<WorkOrder> getWorkOrder(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize,@Param("beginTime") Long begin, @Param("endTime") Long end,
                                         @Param("orderStatus") Integer orderStatus,@Param("maintainerId") Integer maintainerId, @Param("areaId") String areaId,
                                         @Param("projectId") String projectId,@Param("roomId") String roomId);

    List<WorkOrder> getAllWorkOrderTwo(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize,@Param("beginTime") String begin, @Param("endTime") String end,
                                               @Param("orderStatus") Integer orderStatus,@Param("maintainerId") Integer maintainerId, @Param("areaId") String areaId,
                                               @Param("projectId") String projectId,@Param("roomId") String roomId);

    /**
     *事件记录 告警列表
     * @param pageNum
     * @param pageSize
     * @param begin
     * @param end
     * @param rank
     * @param faultTypes
     * @param orderStatus
     * @param roomName
     * @param deviceName
     * @param deviceAddress
     * @return
     */
    List<WorkOrder> getIncidentRecord(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize,@Param("beginTime") Long begin, @Param("endTime") Long end,
                                          @Param("rank") Integer rank,@Param("faultTypes") Integer faultTypes,@Param("orderStatus") Integer orderStatus,
                                          @Param("roomName") String roomName, @Param("deviceName") String deviceName,@Param("deviceAddress") String deviceAddress,@Param("projectId") Integer projectId);


    int updateFlag(@Param("orderDeliveryId") String orderDeliveryId);

    int updateMaintainer(WorkOrder record);

    int selectBydeviceId(String navId);

    int resetOrderStatues();


    /**
     * 运维人员待处理的工单集合
     * @return
     */
    List<WorkOrder> getPendingOrder(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize);


    /**
     * 运维人员处理中的工单集合
     * @param maintainerId
     * @return
     */
    List<WorkOrder> getBeingProcessedOrderByMaintainerId(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize,@Param("maintainerId")String maintainerId);

    /**
     * 运维人员处理成功的工单集合
     * @param maintainerId
     * @return
     */
    List<WorkOrder> getGoodOrderByMaintainerId(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize,@Param("maintainerId")String maintainerId);

    /**
     * 运维人员待处理的数量
     * @return
     */
    Integer getPendingOrderNumber(@Param("maintainerId")String maintainerId);

    /**
     * 运维人员处理中的数量
     * @param maintainerId
     * @return
     */
    Integer getBeingProcessedOrderNumber(@Param("maintainerId")String maintainerId);

    /**
     * 客户待处理工单的数量
     * @param projectId
     * @return
     */
    Integer getPendingOrderNumberByProjectId(@Param("projectId")Integer projectId);


    /**
     * 客户处理中工单的数量
     * @param projectId
     * @return
     */
    Integer getBeingProcessedOrderNumberByProjectId(@Param("projectId")Integer projectId);

    /**
     * 客户待处理的工单集合
     * @param projectId
     * @return
     */
    List<WorkOrder> getPendingOrderByProjectId(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize,@Param("projectId")Integer projectId);

    /**
     * 运维人员的系统告警月报
     * @return
     */
    OrderReport getOrderCountByMonth();


    /**
     * 运维人员的系统告警周报
     * @param weekStartTime
     * @param weekEndTime
     * @return
     */
    OrderReport getOrderCountByWeek(@Param("weekStartTime")String weekStartTime,@Param("weekEndTime") String weekEndTime);

    /**
     * 运维人员的系统告警年报
     * @return
     */
    OrderReport getOrderCountByYear();

    /**
     * 客户的系统告警月报
     * @param projectId
     * @return
     */
    OrderReport getOrderCountByMonthByProjectId(@Param("projectId")Integer projectId);

    /**
     * 客户的系统告警周报
     * @param weekStartTime
     * @param weekEndTime
     * @param projectId
     * @return
     */
    OrderReport getOrderCountByWeekByProjectId(@Param("weekStartTime")String weekStartTime,@Param("weekEndTime") String weekEndTime,@Param("projectId") Integer projectId);

    /**
     * 客户的系统告警年报
     * @param projectId
     * @return
     */
    OrderReport getOrderCountByYearByProjectId(@Param("projectId")Integer projectId);

    /**
     * 运运维人员故障完成度报表,处理中的工单数量年报
     * @return
     */
    OrderReport getOrderBeingProcessedCountByYear();

    /**
     * 运维人员故障完成度报表,已完成的工单数量年报
     * @return
     */
    OrderReport getOrderGoodCountByYear();

    /**
     * 运运维人员故障完成度报表,处理中的工单数量月报
     * @return
     */
    OrderReport getOrderBeingProcessedCountByMonth();

    /**
     * 运运维人员故障完成度报表,已完成的工单数量月报
     * @return
     */
    OrderReport getOrderGoodCountByMonth();

    /**
     * 运运维人员故障完成度报表,处理中的工单数量周报
     * @param weekStartTime
     * @param weekEndTime
     * @return
     */
    OrderReport getOrderBeingProcessedCountByWeek(@Param("weekStartTime")String weekStartTime,@Param("weekEndTime") String weekEndTime);

    /**
     * 运运维人员故障完成度报表,已完成的工单数量周报
     * @param weekStartTime
     * @param weekEndTime
     * @return
     */
    OrderReport getOrderGoodCountByWeek(@Param("weekStartTime")String weekStartTime,@Param("weekEndTime") String weekEndTime);

    /**
     * 客户故障完成度报表,处理中的工单数量年报
     * @param projectId
     * @return
     */
    OrderReport getOrderBeingProcessedCountYearByProjectId(@Param("projectId")Integer projectId);

    /**
     * 客户故障完成度报表,已完成的工单数量年报
     * @param projectId
     * @return
     */
    OrderReport getOrderGoodCountYearByProjectId(@Param("projectId")Integer projectId);

    /**
     * 客户故障完成度报表,处理中的工单数量月报
     * @param projectId
     * @return
     */
    OrderReport getOrderBeingProcessedCountMonthByProjectId(@Param("projectId")Integer projectId);

    /**
     * 客户故障完成度报表,已完成的工单数量月报
     * @param projectId
     * @return
     */
    OrderReport getOrderGoodCountMonthByProjectId(@Param("projectId")Integer projectId);

    /**
     * 客户故障完成度报表,处理中的工单数量周报
     * @param weekStartTime
     * @param weekEndTime
     * @param projectId
     * @return
     */
    OrderReport getOrderBeingProcessedCountWeekByProjectId(@Param("weekStartTime")String weekStartTime,@Param("weekEndTime") String weekEndTime, @Param("projectId")Integer projectId);

    /**
     * 客户故障完成度报表,已完成的工单数量周报
     * @param weekStartTime
     * @param weekEndTime
     * @param projectId
     * @return
     */
    OrderReport getOrderGoodCountWeekByProjectId(@Param("weekStartTime")String weekStartTime,@Param("weekEndTime") String weekEndTime,@Param("projectId") Integer projectId);


    /**
     * 客服处理中的工单集合
     * @param pageNum
     * @param pageSize
     * @param projectId
     * @return
     */
    List<WorkOrder> getBeingProcessedOrderByProjectId(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize,@Param("projectId")Integer projectId);

    /**
     * 运运维人员处理中的工单集合
     * @param pageNum
     * @param pageSize
     * @return
     */
    List<WorkOrder> getBeingProcessedOrder(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize);

    /**
     * 完成的工单集合
     * @param pageNum
     * @param pageSize
     * @return
     */
    List<WorkOrder> getGoodOrder(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize);

    /**
     * 客户的完成的工单集合
     * @param pageNum
     * @param pageSize
     * @param projectId
     * @return
     */
    List<WorkOrder> getGoodOrderByProjectId(@Param("pageNumKey") Integer pageNum, @Param("pageSizeKey") Integer pageSize, @Param("projectId")Integer projectId);

    Integer getBeingProcessedOrderNumberSum();

    int updateOrderStatusById(@Param("orderStatus")Integer orderStatus, @Param("dispose") String dispose, @Param("illustrate")String illustrate, @Param("reason") String reason, @Param("date") Date date, @Param("id")Integer id);

    /**
     * App事件记录
     * @param pageNum
     * @param pageSize
     * @param startTime
     * @param endTime
     * @param faultTypes
     * @return
     */
    List<WorkOrder> getIncidentRecordByFaultTypes(@Param("pageNumKey") Integer pageNum,@Param("pageSizeKey") Integer pageSize, @Param("startTime")String startTime,@Param("endTime") String endTime,@Param("faultTypes") Integer faultTypes);
    List<WorkOrder> getWorkOrderByUserMaintainerId(String maintainerId);

    WorkOrder getWorkOrderByfaultTimeByProjectId(Integer projectId);

    int batchUpdateOrderStatus(@Param("array")String[] ids,@Param("orderStatus")Integer orderStatus);

    void updateOrderStatusByProjectId(Integer projectId);

    void updateAllOrderStatus();

    WorkOrder getNewWorkOrderByProjectId(Integer projectId);

    WorkOrder getWorkOrderByMaintainerId(String maintainerId);

    WorkOrder getWorkOrderByDeliveryName(@Param("deviceName")String deviceName,@Param("fault")String fault);

    Integer getPendingOrderNumberSum();

    List<WorkOrder> getPendingOrderByMaintainerId(@Param("pageNumKey")Integer pageNum, @Param("pageSizeKey")Integer pageSize, @Param("maintainerId")String maintainerId);

    int affirmOrderStatusById(Integer id);

    void updateWorkOrderById(WorkOrder workOrder);
    /* 按设备id 查询报警信息*/
    List<OpsReport> queryByDeviceId(String deviceId);

    List<WorkOrder> getIncidentRecordByFaultTypesProjectId(Integer pageNum, Integer pageSize, String startTime, String endTime, Integer faultTypes, Integer projectId);

    int queryProjectOrderNumberSum(String projectId);

    List<WorkOrder> getWorkOrderByProjectId(String projectId);

    WorkOrder getWorkOrderByOrderDeliveryId(String orderDeliveryId);

    WorkOrder getMaintainerIdWorkOrderByProjectId(String projectId);

   List<WorkOrder> getOrderByMaintainerId(String maintainerId);
}
